SynchronizedKeyedCollection

Ecng.Collections

Represents a thread-safe keyed collection that provides synchronization for its operations.

继承自: KeyedCollection<T, T>

实现: ISynchronizedCollection<KeyValuePair<T, T>>, ISynchronizedCollection, ISynchronizable, ICollection<KeyValuePair<T, T>>, IEnumerable<KeyValuePair<T, T>>, IEnumerable

构造函数

SynchronizedKeyedCollection
protected SynchronizedKeyedCollection()
synchronizedKeyedCollection = SynchronizedKeyedCollection()

Initializes a new instance of the SynchronizedKeyedCollection class.

SynchronizedKeyedCollection
protected SynchronizedKeyedCollection(IEqualityComparer<TKey> comparer)
synchronizedKeyedCollection = SynchronizedKeyedCollection(comparer)

Initializes a new instance of the SynchronizedKeyedCollection class with the specified equality comparer.

comparer
The equality comparer to use when comparing keys.

属性

Item
public override TValue Item { set; }
synchronizedKeyedCollection.Item = value

Gets or sets the value associated with the specified key.

key
The key of the value to get or set.

返回值: The value associated with the specified key.

SyncDict
private SynchronizedDictionary<TKey, TValue> SyncDict { get; }
value = synchronizedKeyedCollection.SyncDict

Gets the synchronized dictionary used internally by the collection.

SyncRoot
public Lock SyncRoot { get; }
value = synchronizedKeyedCollection.SyncRoot

Gets the synchronization root object used to synchronize access to the collection.

方法

Clear
public override void Clear()
synchronizedKeyedCollection.Clear()

Removes all keys and values from the collection.

EnterScope
public Scope EnterScope()
result = synchronizedKeyedCollection.EnterScope()

Enters a synchronized scope for thread-safe operations on the collection.

返回值: A Scope that represents the synchronized scope.

Remove
public override bool Remove(TKey key)
result = synchronizedKeyedCollection.Remove(key)

Removes the value with the specified key from the collection.

key
The key of the element to remove.

返回值: true if the element is successfully found and removed; otherwise, false.